package org.example.teaView;

import javax.swing.*;
import java.awt.*;

public class AddTopicView extends JFrame implements Runnable{
    HandleAddTopic handleAddTopic;
    JButton back,add;
    JTextField inputID,inputSelect_A,inputSelect_B,inputSelect_C,inputSelect_D,input_ans,hintMess;
    JTextArea inputName;
    JScrollPane js;

    AddTopicView(){
        init();
        addTopicListener();
    }

    private void init() {
        this.setSize(512,512);
        this.setDefaultCloseOperation(3);
        this.setLocationRelativeTo(null);
        this.setAlwaysOnTop(true);
        this.setLayout(null);
        this.setVisible(true);
        this.setTitle("添加题目页面-3220608045吉治霖软件2202");

        //ID:  设置
        Font font = new Font(null,1,16);
        JLabel IDText = new JLabel("题目序号：");
        IDText.setFont(font);
        IDText.setBounds(100,35,110,22);
        this.getContentPane().add(IDText);

        inputID = new JTextField();
        inputID.setBounds(190,35,150,22);
        this.getContentPane().add(inputID);
        //题目内容  设置
        JLabel nameText = new JLabel("题目：");
        nameText.setFont(font);
        nameText.setBounds(100,75,55,22);
        this.getContentPane().add(nameText);

        inputName = new JTextArea();
        inputName.setLineWrap(true);
        js = new JScrollPane(inputName);
        js.setBounds(150,75,300,88);
        this.getContentPane().add(js);
        //选项A:  设置
        JLabel Select_A = new JLabel("选项A：");
        Select_A.setFont(font);
        Select_A.setBounds(100,185,80,22);
        this.getContentPane().add(Select_A);

        inputSelect_A = new JTextField();
        inputSelect_A.setBounds(190,185,150,22);
        this.getContentPane().add(inputSelect_A);
        //选项B:  设置
        JLabel Select_B = new JLabel("选项B：");
        Select_B.setFont(font);
        Select_B.setBounds(100,225,80,22);
        this.getContentPane().add(Select_B);

        inputSelect_B = new JTextField();
        inputSelect_B.setBounds(190,225,150,22);
        this.getContentPane().add(inputSelect_B);
        //选项C:  设置
        JLabel Select_C = new JLabel("选项C：");
        Select_C.setFont(font);
        Select_C.setBounds(100,265,80,22);
        this.getContentPane().add(Select_C);

        inputSelect_C = new JTextField();
        inputSelect_C.setBounds(190,265,150,22);
        this.getContentPane().add(inputSelect_C);
        //选项D:  设置
        JLabel Select_D = new JLabel("选项D：");
        Select_D.setFont(font);
        Select_D.setBounds(100,305,80,22);
        this.getContentPane().add(Select_D);

        inputSelect_D = new JTextField();
        inputSelect_D.setBounds(190,305,150,22);
        this.getContentPane().add(inputSelect_D);
        //答案:  设置
        JLabel ans = new JLabel("答案：");
        ans.setFont(font);
        ans.setBounds(100,345,55,22);
        this.getContentPane().add(ans);

        input_ans = new JTextField();
        input_ans.setBounds(190,345,150,22);
        this.getContentPane().add(input_ans);
        // 添加题库按钮 设置
        add = new JButton("添加");
        add.setBounds(130,395,80,30);
        this.getContentPane().add(add);
        // 返回题库按钮 设置
        back = new JButton("返回");
        back.setBounds(230,395,80,30);
        this.getContentPane().add(back);
        //提示框
        hintMess = new JTextField(20);
        hintMess.setEditable(false);
        hintMess.setBounds(50,445,380,30);
        this.getContentPane().add(hintMess);
    }

    private void addTopicListener() {

        handleAddTopic = new HandleAddTopic();// HandleAddWord
        handleAddTopic.setAddTopicView(this);// HandleAddWord
        add.addActionListener(handleAddTopic);
        back.addActionListener(handleAddTopic);

    }

    @Override
    public void run() {

    }
}
